<?php
/**
 * Created By Project
 * Author: 陈东
 * Copyright：陈东
 * Source Code：陈东
 * Explain：I shall not authorize for any other commercial purposes, law breakers must be prosecuted.
 */
namespace Live\Controller;
use Think\Controller;

class LoginController extends Controller {
    /*
     * 登陆页面
     */
    public function index(){
//    	if(!empty(session('userinfo'))){
//    		$this->redirect('/Live/Login/index');
//    	}
    	$this->display();
    }
    /*
     * 注销
     */
    function logout(){
    	session(null);
    	$this->redirect('/Live/Login/index');
    }
    /*
     * 登陆验证
     */
    public function enter(){
    	$username = I('post.username');
    	$userpass = I('post.userpass');
    	$user = D(C('TABLE_USER'));
    	$where['username'] = $username;
    	$result = $user->where($where)->find();
    	if(!empty($result)){
    		if($result['userpass']==md5($userpass)){
    			session('userinfo',$result); //用户信息
    			$this->redirect('/Live');
    		}else{
    			$this->error('密码错误','',1);
    		}
    	}else{
    		$this->error('用户名不存在','',1);
    	}
    }


}